package org.example.singleprinciple;

import lombok.Data;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author wf
 * @description 单一原则
 */

@SpringBootTest
public class SinglePrinciple2 {

    @Resource
    private Vehicle2 vehicle2;

    /*public static void main(String[] args) {
        Vehicle2 vehicle2 = new Vehicle2();
        vehicle2.run("汽车");
        vehicle2.runAir("飞机");
        vehicle2.runWater("轮船");
    }*/

    @Test
    void runTest() {
        vehicle2.run("汽车");
    }

}

@Data
@Component
class Vehicle2 {
    public void run(String vehicle) {
        System.out.println(vehicle + "在公路上跑");
    }

    public void runAir(String vehicle) {
        System.out.println(vehicle + "在天空中运行");
    }

    public void runWater(String vehicle) {
        System.out.println(vehicle + "在水中运行");
    }
}




